﻿
//Author: 张亚涛
//createtime:2016-01-14 21:13:10
//Description: 

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;
using DAL;

namespace BLL
{

    /// <summary>
    /// 该类提供了一系列操作 "MemberRelation" 表的方法;
    /// </summary>
    public class MemberRelationService
    {
        #region .对本表的维护.
        #region select data
        /// <summary>
        /// 返回MemberRelation表的所有数据  
        /// </summary>
        /// <returns></returns>        
        public static List<MemberRelation> GetAllMemberRelation()
        {
            return MemberRelationBase.GetAllMemberRelation();
        }
        /// <summary>
        /// 根据MemberRelation表的MemberID字段返回数据  
        /// </summary>
        /// <param name="memberID">MemberID</param>
        /// <returns></returns>        
        public static MemberRelation GetMemberRelationByOpenID(string openID)
        {
            return MemberRelationBase.GetMemberRelationByOpenID(openID);
        }
        ///<summary>
        ///获取会员家谱
        ///</summary>
        /// <param name="memberID">会员ID</param>
        ///<returns>[PartnerID2,PartnerID3]</returns>
        public static string[] GetFamily(string openID)
        {
            string[] res = new string[2];
            string p2 = "";
            string p3 = "";

            MemberRelation mr = MemberRelationBase.GetMemberRelationByOpenID(openID);
            if (mr != null)
            {
                p2 = mr.PartnerID;
                p3 = mr.PartnerID2;
            }

            res[0] = p2;
            res[1] = p3;
            return res;
        }
        #endregion
        #region delete data
        /// <summary>
        /// 根据MemberRelation表的MemberID字段删除数据 
        /// </summary>
        /// <param name="memberID">memberID</param>
        /// <returns>返回受影响的行数</returns>
        public static int DeleteMemberRelationByMemberID(string memberID)
        {
            return MemberRelationBase.DeleteMemberRelationByMemberID(memberID);
        }
        #endregion
        #region insert data
        /// <summary>
        /// 向MemberRelation表插入一条数据，插入成功则返回自增列数值，插入不成功则返回-1 
        /// </summary>
        /// <param name="memberRelation">MemberRelation</param>        
        /// <returns></returns>
        public static int AddMemberRelation(MemberRelation memberRelation)
        {
            return MemberRelationBase.AddMemberRelation(memberRelation);
        }
        #endregion
        #endregion

        #region .SQL语句汇总.
        /// <summary>
        /// 向MemberRelation表插入一条数据 （SQL语句）
        /// </summary>
        /// <param name="m">MemberRelation</param>       
        /// <returns></returns>        
        public static string AddMemberRelation_SQL(MemberRelation m)
        {
            return MemberRelationBase.AddMemberRelation_SQL(m);
        }
        /// <summary>
        /// 返回MemberRelation表的所有数据（SQL语句） 
        /// </summary>
        /// <returns></returns>        
        public static string GetAllMemberRelation_SQL()
        {
            return MemberRelationBase.GetAllMemberRelation_SQL();
        }
        #endregion
    }
}